package com.lzx.iteam;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.*;
import com.lzx.iteam.base.FindViewById;
import com.lzx.iteam.base.MyBaseActivity;

import static android.R.attr.id;

/**
 * Created by Megan on 16/8/19.
 */
public class CRMListSearchActivity extends MyBaseActivity implements View.OnClickListener {

    @FindViewById(id = R.id.title_ll_back)
    private LinearLayout mLlBack;
    @FindViewById(id = R.id.title_tv_center)
    private TextView mTvTitle;

    @FindViewById(id = R.id.lv_crm_list_search_list)
    ListView mLvList;
    @FindViewById(id = R.id.ll_crm_search_no_data)
    LinearLayout mLlNoData;
    @FindViewById(id = R.id.et_list_search_edit)
    EditText mEtText;
    private String mGroupId;
    private String mCRMId;
    private String mType;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState, R.layout.crm_list_search_layout);
    }


    @Override
    public void onClick(View v) {
        mLlBack.setOnClickListener(this);

    }

    @Override
    public void initListener() {
        mLvList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(CRMListSearchActivity.this, CRMContactActivity.class);
                intent.putExtra("clue_id", mCRMId);
                intent.putExtra("group_id", mGroupId);
                intent.putExtra("type", mType);
                startActivity(intent);
            }
        });
        mEtText.addTextChangedListener(mTextWatcher);

    }

    private TextWatcher mTextWatcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (mEtText != null) {
                String channleText = mEtText.getText().toString().trim();
                if (!channleText.equals("")) {

                } else {
                    mLlNoData.setVisibility(View.GONE);

                }
            }
        }
    };


    @Override
    public void initData() {
        mTvTitle.setText("搜索");
        Intent intent = getIntent();
        mGroupId = intent.getStringExtra("group_id");
        mType = intent.getStringExtra("type");

    }
}
